package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchDeviceMonitor;
import com.ruoyi.system.service.IDispatchDeviceMonitorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备监控Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchDeviceMonitor")
public class DispatchDeviceMonitorController extends BaseController
{
    @Autowired
    private IDispatchDeviceMonitorService dispatchDeviceMonitorService;

    /**
     * 查询设备监控列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchDeviceMonitor:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchDeviceMonitor dispatchDeviceMonitor)
    {
        startPage();
        List<DispatchDeviceMonitor> list = dispatchDeviceMonitorService.selectDispatchDeviceMonitorList(dispatchDeviceMonitor);
        return getDataTable(list);
    }

    /**
     * 导出设备监控列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchDeviceMonitor:export')")
    @Log(title = "设备监控", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchDeviceMonitor dispatchDeviceMonitor)
    {
        List<DispatchDeviceMonitor> list = dispatchDeviceMonitorService.selectDispatchDeviceMonitorList(dispatchDeviceMonitor);
        ExcelUtil<DispatchDeviceMonitor> util = new ExcelUtil<DispatchDeviceMonitor>(DispatchDeviceMonitor.class);
        util.exportExcel(response, list, "设备监控数据");
    }

    /**
     * 获取设备监控详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchDeviceMonitor:query')")
    @GetMapping(value = "/{deviceMonitorId}")
    public AjaxResult getInfo(@PathVariable("deviceMonitorId") Long deviceMonitorId)
    {
        return success(dispatchDeviceMonitorService.selectDispatchDeviceMonitorByDeviceMonitorId(deviceMonitorId));
    }

    /**
     * 新增设备监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchDeviceMonitor:add')")
    @Log(title = "设备监控", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchDeviceMonitor dispatchDeviceMonitor)
    {
        return toAjax(dispatchDeviceMonitorService.insertDispatchDeviceMonitor(dispatchDeviceMonitor));
    }

    /**
     * 修改设备监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchDeviceMonitor:edit')")
    @Log(title = "设备监控", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchDeviceMonitor dispatchDeviceMonitor)
    {
        return toAjax(dispatchDeviceMonitorService.updateDispatchDeviceMonitor(dispatchDeviceMonitor));
    }

    /**
     * 删除设备监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchDeviceMonitor:remove')")
    @Log(title = "设备监控", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceMonitorIds}")
    public AjaxResult remove(@PathVariable Long[] deviceMonitorIds)
    {
        return toAjax(dispatchDeviceMonitorService.deleteDispatchDeviceMonitorByDeviceMonitorIds(deviceMonitorIds));
    }
}
